package com.niodata.dp.core.service;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ServiceInfoMapper {

  @Select("select * from SERVICE")
  @ResultMap("serviceInfoResult")
  List<ServiceInfo> getAllSystemServices();

  @Update("update SERVICE set DESCRIPTION=#{service.description},"
        + "ENABLED=#{service.enabled} where SER_NAME=#{service.name}")
  void updateServiceInfo(@Param("service") ServiceInfo info);

  @Insert("insert into SERVICE (SER_NAME,DESCRIPTION,ENABLED) VALUES(#{service.name},"
        + "#{service.description},#{service.enabled})")
  void addServiceInfo(@Param("service") ServiceInfo serviceInfo);

  @Delete("delete from SERVICE WHERE SER_NAME=#{name}")
  void removeService(@Param("name") String name);

}
